#include <bits/stdc++.h>
using namespace std;
const int N=1e5;
int d[N+5],v[N+5],a[N+5],p[N+5];
double l[N+5],r[N+5];
bool be[10*N+5];
int num;
int t;
int ans;
int n,m,L,V;
signed main(){
	//freopen("/home/csps/Desktop/CSP-S/detect/detect1.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while (t--){
		ans=0;
		num=0;
		cin>>n>>m>>L>>V;
		for (int i=1;i<=n;i++){
			cin>>d[i]>>v[i]>>a[i];
		}
		for (int i=1;i<=m;i++){
			cin>>p[i];
			be[p[i]]=1;
		}
		for (int i=1;i<=n;i++){
			if (v[i]<=V&&a[i]<=0){
				a[i]=r[i]=-1;
				continue;
			}
			else if (v[i]>V&&a[i]>=0){
				l[i]=d[i];
				r[i]=L;
			}
			else if (v[i]>V&&a[i]<0){//chaosu jiansu
				l[i]=d[i];
				//double tim=(V-v[i])*1.0/a[i];
				if (((V*V-v[i]*v[i])/2.0/(a[i]*1.0))>L-d[i]){
					r[i]=L;
				}
				else {
					r[i]=(V*V-v[i]*v[i])/2.0/a[i]+d[i];
					if (r[i]==(int)r[i]){
						r[i]=r[i]-1;
					}
					else {
						r[i]=(int)r[i]-1;
					}
				}
			}
			else if (v[i]<=V&&a[i]>0){//buchaosu  jiasu
				double tim=(V-v[i])*1.0/a[i];
				if (v[i]*tim+a[i]*tim*tim/2+d[i]>L){
					l[i]=r[i]=-1;
					continue;
				}
				else {
					r[i]=L;
					l[i]=(V*V-v[i]*v[i])/2.0/a[i]+d[i];
					if (l[i]!=(int)l[i]){
						l[i]=(int)l[i]+1;
					}
					else{
						l[i]=(int )l[i]+1;
					}
				}
			}
		}
		for (int i=1;i<=n;i++){
			bool flag=1;
			for (int j=l[i];j<=r[i];j++){
				if (be[j]){
					ans++;
					cout<<i<<" ";
					flag=0;
					break;
				}
			}
		}
		cout<<ans<<" "<<endl;
	}
	
//	for (int i=1;i<=n;i++){
//		cout<<l[i]<<" "<<r[i]<<endl;
//	}
	return 0;
}/*9 10 114934 719
62115 915 -6
44976 920 -17
21788 877 -1
38609 839 -3
44828 982 -8
9713 1000 -109
61421 860 -922
16064 918 -2
33522 989 -11
13230 19868 37544 44774 45209 54175 61486 62595 87581 101248*/
